package com.java110.mall.shop.smo.impl;


import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.PageDto;
import com.java110.dto.vipUser.ShopVipLevelDto;
import com.java110.intf.shop.IShopVipLevelInnerServiceSMO;
import com.java110.po.shop.ShopVipLevelPo;
import com.java110.mall.shop.dao.IShopVipLevelServiceDao;
import com.java110.utils.util.BeanConvertUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 会员等级内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class ShopVipLevelInnerServiceSMOImpl extends BaseServiceSMO implements IShopVipLevelInnerServiceSMO {

    @Autowired
    private IShopVipLevelServiceDao shopVipLevelServiceDaoImpl;


    @Override
    public int saveShopVipLevel(@RequestBody ShopVipLevelPo shopVipLevelPo) {
        int saveFlag = 1;
        shopVipLevelServiceDaoImpl.saveShopVipLevelInfo(BeanConvertUtil.beanCovertMap(shopVipLevelPo));
        return saveFlag;
    }

    @Override
    public int updateShopVipLevel(@RequestBody ShopVipLevelPo shopVipLevelPo) {
        int saveFlag = 1;
        shopVipLevelServiceDaoImpl.updateShopVipLevelInfo(BeanConvertUtil.beanCovertMap(shopVipLevelPo));
        return saveFlag;
    }

    @Override
    public int deleteShopVipLevel(@RequestBody ShopVipLevelPo shopVipLevelPo) {
        int saveFlag = 1;
        shopVipLevelPo.setStatusCd("1");
        shopVipLevelServiceDaoImpl.updateShopVipLevelInfo(BeanConvertUtil.beanCovertMap(shopVipLevelPo));
        return saveFlag;
    }

    @Override
    public List<ShopVipLevelDto> queryShopVipLevels(@RequestBody ShopVipLevelDto shopVipLevelDto) {

        //校验是否传了 分页信息

        int page = shopVipLevelDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            shopVipLevelDto.setPage((page - 1) * shopVipLevelDto.getRow());
        }

        List<ShopVipLevelDto> shopVipLevels = BeanConvertUtil.covertBeanList(shopVipLevelServiceDaoImpl.getShopVipLevelInfo(BeanConvertUtil.beanCovertMap(shopVipLevelDto)), ShopVipLevelDto.class);

        return shopVipLevels;
    }


    @Override
    public int queryShopVipLevelsCount(@RequestBody ShopVipLevelDto shopVipLevelDto) {
        return shopVipLevelServiceDaoImpl.queryShopVipLevelsCount(BeanConvertUtil.beanCovertMap(shopVipLevelDto));
    }

    public IShopVipLevelServiceDao getShopVipLevelServiceDaoImpl() {
        return shopVipLevelServiceDaoImpl;
    }

    public void setShopVipLevelServiceDaoImpl(IShopVipLevelServiceDao shopVipLevelServiceDaoImpl) {
        this.shopVipLevelServiceDaoImpl = shopVipLevelServiceDaoImpl;
    }
}
